import { Fragment } from '@/components/Fragment'; import { View } from '@aws-amplify/ui-react'; import { ViewDemo } from './demo'; import { Example, ExampleCode } from '@/components/Example'; import { AccessibilityExample, CustomAttributesExample, DefaultViewExample, DisabledStateExample, SetRenderedHTML, StylePropsExample, } from './examples'; ## Demo ## Usage Import the View component. ```jsx file=./examples/DefaultViewExample.tsx ``` ### Set rendered HTML element To change the HTML element rendered by the View, use the `as` prop. View renders a `
` by default. ```jsx file=./examples/SetRenderedHTML.tsx ``` ### Disabled state To mark a View as disabled, pass the `isDisabled` prop. ```jsx file=./examples/DisabledStateExample.tsx ``` ### Accessibility The example below demonstrates setting an `aria-label` attribute and `role` for an icon button. ```jsx file=./examples/AccessibilityExample.tsx ``` ### Standard HTML attributes View will accept any of the standard HTML attributes that its underlying HTML element accepts. ```jsx file=./examples/CustomAttributesExample.tsx ``` ## CSS Styling ### Local styling To override styling on a specific View, you can use a class selector or style props. _Using a class selector:_ ```css /* styles.css */ .mountain-view { background-color: #b7daf9; display: block; font-size: 5em; text-align: center; } ``` ```jsx import { View } from '@aws-amplify/ui-react'; import './styles.css'; export const ClassNameExample = () => { return 🏔; }; ``` 🏔 _Using style props:_ ```jsx file=./examples/StylePropsExample.tsx ```